﻿@using GoodMan.Infrastructure.Entities.Entity;
@{
    ViewBag.Title = "产品分类列表";
    Layout = "~/Areas/WorkSpace/Views/Shared/_CollegeAdminTemplete.cshtml";

    ItemListBox<ProductCategory> data = ViewBag.Categorys;
}
@section head{
    <script type="text/javascript">
        function showhide(obj, a, b, c) {
            a = parseInt(a);
            b = parseInt(b);
            c = parseInt(c);
            if (c > 0) {
                $(".tab" + c).toggle();
                return false;
            }
            if (b > 0) {
                $(".tab" + b).toggle();
                if ($(".tab" + b).css("display") == 'none') {
                    $(obj).html("[+]");
                } else {
                    $(obj).html("[-]");
                }
                return false;
            }
            if (a > 0) {
                $(".tab" + a).toggle();
                if ($(".tab" + a).css("display") == 'none') {
                    $(obj).html("[+]");
                } else {
                    $(obj).html("[-]");
                }
                return false;
            }
            return true;
        }
     
    </script>
}
<div id="content-header">
    <h1>
        商品分类</h1>
</div>
<div id="breadcrumb">
    <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>
        首页</a> <a href="#" class="tip-bottom">商品管理</a> <a href="#" class="current">商品分类</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-th"></i></span>
                    <h5>
                        商品分类列表</h5>
                </div>
                <div class="widget-content nopadding">
                    <table class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th width="5%">
                                </th>
                                <th>
                                    分类名称
                                </th>
                                <th width="15%">
                                    状态
                                </th>
                                <th width="20%">
                                    操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @{
                                if (data != null && data.Data != null && data.Data.Any())
                                {
                                    foreach (var item in data.Data)
                                    {
                                <tr>
                                    <td class="center">
                                        <a href="javascript:;" onclick="return showhide(this,'@item.Id','0')">
                                            @{if (item.productCategorys != null && item.productCategorys.Count > 0)
                                              {@Html.Raw("[+]")}}
                                        </a>
                                    </td>
                                    <td>@item.CategoryName
                                    </td>
                                    <td class="center">
                                        @{if (item.IsActive)
                                          { 
                                              <a href="/CollegeAdmin/ChangeCategoryState?productCategoryId=@item.Id" title="点击禁用">启用</a>
                                            }   
                                          else
                                          {<a href="/CollegeAdmin/ChangeCategoryState?productCategoryId=@item.Id" title="点击启用">禁用</a>}}
                                    </td>
                                    <td class="center">
                                        <a href="/workspace/CollegeAdmin/ProductCategoryDetail?id=@item.Id" class="btn btn-primary btn-mini">
                                            编辑</a>
                                        @if (item.productCategorys != null && item.productCategorys.Count > 0)
                                        {<a href="#" class="btn btn-danger btn-mini" style="display: none;">删除</a>}
                                        else
                                        {<a  onclick='return confirm("确定要删除吗?")' href="/CollegeAdmin/DeleteProductCategory?productCategoryId=@item.Id" class="btn btn-danger btn-mini">删除</a>}
                                    </td>
                                </tr> 
                                        if (item.productCategorys != null && item.productCategorys.Count > 0)
                                        {

                                            foreach (var subItem in item.productCategorys)
                                            {
                                <tr class=@Html.Raw("\"tab" + @item.Id + "\"") style="display:none">
                                    <td>
                                    </td>
                                    <td>
                                        &nbsp;&nbsp;├ &nbsp;@subItem.CategoryName
                                    </td>
                                    <td class="center">
                                         @{if (subItem.IsActive)
                                          { 
                                              <a href="/CollegeAdmin/ChangeCategoryState?productCategoryId=@subItem.Id"  title="点击禁用">启用</a>
                                            }   
                                          else
                                          {<a href="/CollegeAdmin/ChangeCategoryState?productCategoryId=@subItem.Id"  title="点击启用">禁用</a>}}
                                    </td>
                                    <td class="center">
                                        <a href="/workspace/CollegeAdmin/ProductCategoryDetail?id=@subItem.Id" class="btn btn-primary btn-mini">
                                            编辑</a> <a  onclick='return confirm("确定要删除吗?")' href="/CollegeAdmin/DeleteProductCategory?productCategoryId=@subItem.Id" class="btn btn-danger btn-mini">删除</a>
                                    </td>
                                </tr>
                                            }
                                        }

                                    }
                                }
                                else
                                {
                                <tr>
                                    <td colspan="4" align="center">
                                        无商品分类数据，请添加
                                    </td>
                                </tr>
                                }
                            }
                        </tbody>
                    </table>
                </div>
            </div>
            @{
                if (ViewBag.isSuccess != null)
                {
                    if (ViewBag.isSuccess)
                    { 
                <div class="alert alert-success">
                    <strong>删除商品分类成功！</strong>
                </div>
                 
                    }
                    else
                    {
                 <div class="alert alert-error">
                    <strong>删除商品分类失败！</strong>
                </div>
                    }
                }
            }
        </div>
    </div>
</div>
@section tail{
<script type="text/javascript">
    $(function () {
        $('#likProduct').addClass('open');
        $('#likProduct').addClass('active');
    });
</script>
